package com.jlnk.androidfmc.presenter;

import android.content.Context;

import com.jlnk.androidfmc.entity.Product;
import com.jlnk.androidfmc.model.RecommendModel;
import com.jlnk.androidfmc.view.RecommendView;

import java.util.List;

public class RecommendPresenter {
    private RecommendView view;
    private RecommendModel model;

    public RecommendPresenter(RecommendView view, Context context) {
        this.view = view;
        this.model = new RecommendModel(context); // 使用传入的context
    }

    public void loadProducts() {
        view.showLoading();
        model.getProducts(new RecommendModel.LoadProductsCallback() {
            @Override
            public void onProductsLoaded(List<Product> productList) {
                view.hideLoading();
                view.showProducts(productList);
            }

            @Override
            public void onError() {
                view.hideLoading();
                view.showError();
            }
        });
    }
}